package facade

import "fmt"

type PowerSupply struct{}

func (p *PowerSupply) TurnOn() {
	fmt.Println("Power supply turned on.")
}
func (p *PowerSupply) TurnOff() {
	fmt.Println("Power supply turned off.")
}

type Display struct{}

func (d *Display) TurnOn() {
	fmt.Println("Display turned on.")
}
func (d *Display) TurnOff() {
	fmt.Println("Display turned off.")
}

type HardDrive struct{}

func (h *HardDrive) TurnOn() {
	fmt.Println("Hard drive turned on.")
}
func (h *HardDrive) TurnOff() {
	fmt.Println("Hard drive turned off.")
}

type Memory struct{}

func (m *Memory) TurnOn() {
	fmt.Println("Memory turned on.")
}
func (m *Memory) TurnOff() {
	fmt.Println("Memory turned off.")
}

type Computer struct {
	powerSupply *PowerSupply
	display     *Display
	hardDrive   *HardDrive
	memory      *Memory
}

func NewComputer() *Computer {
	return &Computer{
		powerSupply: &PowerSupply{},
		display:     &Display{},
		hardDrive:   &HardDrive{},
		memory:      &Memory{},
	}
}

func (c *Computer) TurnOn() {
	c.powerSupply.TurnOn()
	c.memory.TurnOn()
	c.hardDrive.TurnOn()
	c.display.TurnOn()
	fmt.Println("Computer is now on.")
}

func (c *Computer) TurnOff() {
	c.display.TurnOff()
	c.hardDrive.TurnOff()
	c.memory.TurnOff()
	c.powerSupply.TurnOff()
	fmt.Println("Computer is now off.")
}
